package com.czh.www.domain;

public class UsersVo {
    private String userName;
    private String alias;
    private String groupName;
    private String ip;
    private String hostName;

    public UsersVo() {
    }

    public String getGroupName() {
        return this.groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getHostName() {
        return this.hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public String getIp() {
        return this.ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getAlias() {
        return this.alias != null && !"".equals(this.alias) ? this.alias : this.userName;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public static UsersVo changeDataPacket(DataPacket dp) {
        UsersVo uv = new UsersVo();
        uv.setUserName(dp.getSenderName());
        uv.setHostName(dp.getSenderHost());
        String[] buff = dp.getAdditional().split("\u0000");
        if (buff.length >= 2) {
            uv.setAlias(buff[0]);
            uv.setGroupName(buff[1]);
        }

        uv.setIp(dp.getIp());
        return uv;
    }

    public String[] toArray() {
        return new String[]{this.getAlias(), this.groupName, this.hostName, this.ip};
    }
}
